package cn.timetable.web;


import cn.timetable.domain.Student;
import cn.timetable.qo.JsonResult;
import cn.timetable.service.impl.IStudentServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class LoginController {

    @Autowired
    private IStudentServiceImpl studentService;

    /**
     * 登录功能的实现
     *
     * @param username 传入用户名
     * @param password 传入密码
     * @return 返回Json数据
     */
    @RequestMapping("/userlogin")
    @ResponseBody
    public JsonResult login(String username, String password) {
        Student student = studentService.queryStudent(username, password);

        if (student != null) {
            return new JsonResult(true, "登录成功");
        }
        return new JsonResult(false, "账号或密码错误");
    }
}
